package com.jctrip.hotel.source.client;

import java.util.List;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.jctrip.hotel.source.model.atour.req.CancelOrderReq;
import com.jctrip.hotel.source.model.atour.req.CreateOrderReq;
import com.jctrip.hotel.source.model.atour.req.QueryOrderReq;
import com.jctrip.hotel.source.model.atour.req.QueryOrderResp;
import com.jctrip.hotel.source.model.atour.resp.AtourResult;
import com.jctrip.hotel.source.model.atour.resp.CancelOrderResp;
import com.jctrip.hotel.source.model.atour.resp.CityData;
import com.jctrip.hotel.source.model.atour.resp.CreateOrderResp;
import com.jctrip.hotel.source.model.atour.resp.HotelData;
import com.jctrip.hotel.source.model.atour.resp.RoomInventoryData;
import com.jctrip.hotel.source.model.atour.resp.RoomRateData;
import com.jctrip.hotel.source.model.atour.resp.RoomTypeData;

/**
 * @Author henry
 * @Date 2023/5/24 22:04
 * @Description
 */
@FeignClient(name = "AtourClient", url = "${feign.url.atour}")
@RequestMapping(headers = {"accept=application/json"})
public interface AtourClient {
    /**
     * 获取城市列表
     */
    @GetMapping("/atour/openapi/city/getCityList")
    AtourResult<List<CityData>> getCityList(@RequestParam("appId") Integer appId,
                                            @RequestParam("sign") String sign,
                                            @RequestParam("timestamp") Long timestamp);

    /**
     * 获取酒店基础信息
     */
    @GetMapping("/atour/openapi/baoku/hotel/getHotelList")
    AtourResult<List<HotelData>> getHotelList(@RequestParam("appId") Integer appId,
                                              @RequestParam("cityId") Integer cityId,
                                              @RequestParam("sign") String sign,
                                              @RequestParam("timestamp") Long timestamp);

    /**
     * 获取单个酒店信息
     */
    @GetMapping("/atour/openapi/baoku/hotel/getHotel")
    AtourResult<HotelData> getHotel(@RequestParam("appId") Integer appId,
                                    @RequestParam("hotelId") Integer hotelId,
                                    @RequestParam("sign") String sign,
                                    @RequestParam("timestamp") Long timestamp);

    /**
     * 获取酒店房型
     */
    @GetMapping("/atour/openapi/baoku/hotel/getRoomTypeList")
    AtourResult<List<RoomTypeData>> getRoomTypeList(@RequestParam("appId") Integer appId,
                                                    @RequestParam("hotelId") Integer hotelId,
                                                    @RequestParam("sign") String sign,
                                                    @RequestParam("timestamp") Long timestamp);

    /**
     * 获取酒店房价
     */
    @GetMapping("/atour/openapi/baoku/hotel/getRoomRateList")
    AtourResult<List<RoomRateData>> getRoomRateList(@RequestParam("appId") Integer appId,
                                                    @RequestParam("hotelId") Integer hotelId,
                                                    @RequestParam("roomTypeId") Integer roomTypeId,
                                                    @RequestParam("start") String start,
                                                    @RequestParam("end") String end,
                                                    @RequestParam("roomRateTypeId") Integer roomRateTypeId,
                                                    @RequestParam("mebId") Integer mebId,
                                                    @RequestParam("sign") String sign,
                                                    @RequestParam("timestamp") Long timestamp);

    /**
     * 获取酒店库存
     */
    @GetMapping("/atour/openapi/baoku/hotel/getRoomInventoryList")
    AtourResult<List<RoomInventoryData>> getRoomInventoryList(@RequestParam("appId") Integer appId,
                                                              @RequestParam("hotelId") Integer hotelId,
                                                              @RequestParam("roomTypeId") Integer roomTypeId,
                                                              @RequestParam("start") String start,
                                                              @RequestParam("end") String end,
                                                              @RequestParam("roomRateTypeId") Integer roomRateTypeId,
                                                              @RequestParam("mebId") Integer mebId,
                                                              @RequestParam("sign") String sign,
                                                              @RequestParam("timestamp") Long timestamp);

    /**
     * 创建订单
     */
    @PostMapping(value = "/atour/openapi/baoku/order/createOrder",
            headers = {"Content-Type=application/x-www-form-urlencoded"})
    AtourResult<CreateOrderResp> createOrder(@SpringQueryMap CreateOrderReq createOrderReq);

    /**
     * 查询订单
     */
    @PostMapping(value = "/atour/openapi/baoku/order/queryOrder",
            headers = {"Content-Type=application/x-www-form-urlencoded"})
    AtourResult<List<QueryOrderResp>> queryOrder(@SpringQueryMap QueryOrderReq queryOrderReq);

    /**
     * 取消订单
     */
    @PostMapping(value = "/atour/openapi/baoku/order/cancelOrder",
            headers = {"Content-Type=application/x-www-form-urlencoded","accept=text/json;charset=UTF-8"})
    AtourResult<CancelOrderResp> cancelOrder(@SpringQueryMap CancelOrderReq cancelOrderReq);
}
